<template>
    <div>

            <div class="newsinfo_container">
        <div class="body">
        <!-- 大标题 -->
            <h3 class="title">{{newsinfo.wenzhang_name}}</h3>
            <!-- 小标题 -->
            <p class="subtitle">
                <span>发表时间：{{newsinfo.wenzhang_time | dataFormat}}</span>
                <span>点击：{{newsinfo.wenzhang_count}}次</span>
            </p>  
            <hr>
            <div class="content" v-html="newsinfo.neirong">
            </div>
             <!-- <i class="el-icon-star-off" @click="Like()" v-if="!likeflag">({{newsinfo.like}})</i>
             <i class="el-icon-star-on" v-else>({{newsinfo.like}})</i> -->

             <!-- 评论区域 -->
            <commentbox></commentbox>
            </div>
            <div class="aside">
                <img src="../../assets/aaa.png" alt="asd">
                <div class="sticky">
                    <div class="recommend">
                        <div class="recommendTitle">推荐阅读</div>
                        <div class="recommendItem" v-for="item in recommendList" :key="item.title">
                            <a href=""><span>{{item.title}}</span></a>
                            <span>阅读 {{item.click}}</span>
                        </div>
                    </div>
                    <img src="https://tpc.googlesyndication.com/simgad/4097515285375806291?sqp=4sqPyQQrQikqJwhfEAEdAAC0QiABKAEwCTgDQPCTCUgAUAFYAWBfcAJ4AcUBLbKdPg&rs=AOga4qmw_XFnqiKb7bxA_16NNgNFj3NDMw" alt="">
                </div>
            </div>
            </div>
            
           
    </div>
</template>
<script>
//1.导入评论组件
import comment from '../subcomponents/comment.vue'


export default {
    data() {
        return {
            id:this.$route.params.id,
            newsinfo:{
                title:'我的标题',
                click:2,
                add_time:new Date(),
                content:'资讯详细内容',
                like:50,
            },
            recommendList:[
                {title:'Vue实现前后端分离之分页',click:824},
                {title:'写作水平一般的我居然也实现了写作变现',click:43888},
                {title:'7个小众却最让你感到惊艳的APP',click:27042},
                {title:'我月薪3000，周末副业收入1000',click:4963},
                {title:'Vue+nodejs+MySql之周报管理系统-前言',click:689},
            ],
        }
    },
    methods: {
        getNewsInfo(){
            this.$http.get('/news/new_detail/'+this.id).then(res=>{
                // window.console.log(res)
                this.newsinfo = res.data
            })
        },
        getRecommendNewsInfo(){
            this.$http.get('/top/5/7').then(res=>{
                window.console.log(res)
            })
        },
        Like(){
            this.likeflag = !this.likeflag
            this.newsinfo.like+=1

        },
    },
    created() {
        this.getNewsInfo()
        this.getRecommendNewsInfo()
    },
    components:{
        //用来注册子组件的节点
        'commentbox':comment
    }
}
</script>
<style scoped>
.newsinfo_container{
        width: 1050px;
    /* border: 1px solid red; */
    margin-left: 50%;
    padding: 5px 10px;
    transform: translateX(-50%);
    background-color: #fff;
    display: flex;
    justify-content: space-between;
}
.body{
    width: 750px;
    /* background-color: #eee; */
    padding: 15px;
}
.subtitle{
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    color: #226aff;
}
.title{
    text-align: center;
}
.content{
    min-height: 300px;
}
i{
    font-size: 25px;
    position: absolute;
    right: 30px;
    cursor: pointer;
}
.aside{
    /* background-color: #eee; */
    width: 270px;
}
.aside img{
    width: 270px;
}
.sticky{
    position: sticky;
    top: 65px;
}
.recommend{
    padding: 10px;
}
.recommendTitle {
    border-left: 4px solid orange;
    padding-left: 5px;
    margin: 4px 0;
    font-size: 15px;
}
.recommendItem{
    display: flex;
    flex-direction: column;
    margin: 7px 0;
}
.recommendItem span{
 font-size: 12px;
 color: #999;
}
.recommendItem :first-child{
    color: black;
    font-size: 14px;
    
}
</style>>
    